<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>个人信息</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <link rel="stylesheet" href="/static/wx/lib/sui/sm.min.css">
    <link rel="stylesheet" href="/static/wx/lib/sui/sm-extend.min.css">

    <link rel="stylesheet" href="/static/wx/css/reset.css">
    <link rel="stylesheet" href="/static/wx/css/main.css">
    <link rel="stylesheet" href="/static/wx/css/public_main.css">
</head>

<body>
    <div class="page-group">
        <div class="page page-current" id="selfInfo">
            <!-- 主内容 -->
            <div class="content">
                <div class="list-block">
                    <ul>
                        <li>
                            <a href="" class="item-link item-content">
                                <div class="item-inner size-m">
                                    <div class="item-title">头像</div>
                                    <div class="avator-upload">
                                        <input type="hidden" value="{$info.head_img}" id="img">
                                        <img src="{$info.head_img |default=''}" width="30"  id="images"/>
                                    </div>

                                </div>
                            </a>
                            <input class="uploader-input" type="file" accept="image/*" onchange="handleInputChange1(event)"/>

                        </li>
                        <li>
                            <a href="" class="item-content">
                                <div class="item-inner size-m">
                                    <div class="item-title">真实姓名</div>
                                    <div>
                                        <input type="text" placeholder="" value="{$info.username|default=''}" readonly/>
                                    </div>
                                </div>
                            </a>
                        </li>
                        <li>
                            <a href="" class="item-content">
                                <div class="item-inner size-m">
                                    <div class="item-title">手机号</div>
                                    <div>
                                        <input type="text" placeholder="" value="{$info.mobile|default=''}" readonly/>
                                    </div>
                                </div>
                            </a>
                        </li>
                        <li>
                            <a href="" class=" item-content">
                                <div class="item-inner size-m">
                                    {if($info.role_id ==3)}
                                    <div class="item-title">物权单位</div>
                                    {/if}
                                    {if($info.role_id ==1 || $info.role_id == 2)}
                                    <div class="item-title">单位名称</div>
                                    {/if}
                                    {if($info.role_id ==4)}
                                    <div class="item-title">部门</div>
                                    {/if}
                                    <div>
                                        <textarea readonly style="font-size: .75rem;text-align: right;height: 2.2rem;text-align-last: start;">{$info.company_name|default=''}</textarea>
                                        <!-- <input type="text" placeholder=""  value="{$info.company_name|default=''}" readonly/> -->
                                    </div>
                                </div>
                            </a>
                        </li>
                        {if($info.role_id != 3 && $info.role_id != 1) }
                        <li>
                            <a href="" class=" item-content">
                                <div class="item-inner size-m">
                                    <div class="item-title">单位联系人</div>
                                    <div>
                                        {if($info.role_id == 4)}
                                        <input type="text" placeholder=""  value="{$info.sale_man_company|default=''}" readonly/>
                                        {else}
                                        <input type="text" placeholder=""  value="{$info.company_name|default=''}" readonly/>
                                        {/if}
                                    </div>
                                </div>
                            </a>
                        </li>
                        <li>
                            <a href="" class=" item-content">
                                <div class="item-inner size-m">
                                    <div class="item-title">单位联系电话</div>
                                    <div>
                                        <input type="text" placeholder=""  value="{$info.sale_man_linkman|default=''}" readonly/>
                                    </div>
                                </div>
                            </a>
                        </li>
                        <li>
                            <a href="" class=" item-content">
                                <div class="item-inner size-m">
                                    <div class="item-title">身份证</div>
                                    <div>
                                        <input type="text" placeholder=""  value="{$info.card_num|default=''}" readonly/>
                                    </div>
                                </div>
                            </a>
                        </li>
                        {/if}
                        <li>
                            <a href="" class=" item-content">
                                <div class="item-inner size-m">
                                    <div class="item-title">身份证</div>
                                    <div>
                                        <input type="text" placeholder=""  value="{$info.card_num|default=''}" readonly/>
                                    </div>
                                </div>
                            </a>
                        </li>
                    </ul>
                </div>
                <div class="btn-box">
                    <div class="my-btn size-m">
                        <input type="hidden" id="pic" value="">
                        <span class="active" id="submit">保存</span>
                    </div>
                </div>
            </div>
        </div>

    </div>

    <script type='text/javascript' src='/static/wx/lib/sui/zepto.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='/static/wx/lib/sui/sm.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='/static/wx/lib/sui/sm-extend.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='/static/wx/js/upload.js' charset='utf-8'></script>
</body>

</html>
<script>
    $('#submit').on('touchend',function () {
        var head_img = $('#pic').val();
        $.ajax({
            type: 'POST',
            url: "{:url('User/change_head_img')}",
            data: {'head_img':head_img},
            success: function (Json) {
                if (Json.code == 200) {
                    $.alert('保存成功');
                } else {
                    $.alert('保存失败');
                }
            }
        });
    });
    function handleInputChange1(event) {
        var formData = handleInputChange(event);
        uploadImg(formData);

    }
    function  uploadImg(formData) {
        $.ajax({
            type: 'POST',
            url: "{:url('upload/index')}",
            data: formData,
            processData: false,
            contentType: false,
            cache: false,
            success: function (Json) {
                console.log(Json.data)
                if (Json.code == 200) {
                    $.alert('上传成功');
                    var url = decodeURI(Json.data.url)
                    $('#images').attr('src',url);
                    $('#pic').attr('value',url);
                } else {
                    $.alert('上传失败');
                }
            }
        });
    }


</script>